package cuiyt.offer;

/**
 * @author cyt
 * @create 2020-05-26 17:35
 */
public class T32 {

    /**
     * 平衡二叉树， 左右子树的高度差 小于 1
     *
     * @param args
     */
    public static void main(String[] args) {

    }

    boolean flag = false;

    public boolean IsBalanced_Solution(TreeNode root) {
        hight(root);
        return flag;
    }

    int hight(TreeNode root) {
        if (root == null) {
            return 0;
        }
        int left = hight(root.left);

        int right = hight(root.right);

        if (Math.abs(left - right) > 1) {
            flag = false;
        }
        return Math.max(left, right) + 1;
    }

}
